import React, { useState } from 'react'

export default function UseState() {
    const [count, setCount] = useState(0)
    const [user, setUser] = useState({name: 'yuxl', money: 10000})
    const changeUser = () =>{
        setUser({
            ...user,
            money: user.money+100
        })
    }

    return (
        <div>
            <h1>useState 的基本使用</h1>
            <p>当前count:{count}</p>
            <button onClick={() => {setCount(count + 1)}}>点击count++</button>
            <p>yuxl的钱money:{user.money}</p>
            <button onClick={changeUser}>点击 money+100</button>
        </div>
    )
}
